package messages;

import java.util.List;
import java.util.StringTokenizer;

import others.Constants;

public class CallMessage extends Message {
    
    private String userName;

    public CallMessage(List<StringTokenizer> tokens) {
        super("CALL");
        this.parseMessage(tokens);
    }
    
    public CallMessage(String userName) {
        super("CALL");
        this.userName = userName;
    }
   
    // return userName
    @Override
    public String getUserName() {
        return userName;
    }

    // seta userName
    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Override
    public void parseMessage(List<StringTokenizer> tokens) {
        
    	// Captura a primeira linha
        userName=tokens.get(0).nextToken();
            //log
            System.out.println("CALL");
            System.out.println("userName :"+userName);
    }
 
    @Override
    public String writeMessage() {
        String message = "";
        
        message += "CALL " + userName + Constants.CRLF;
        
        return message;
    }    

}
